-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make analysis tree view more "tree like" #1053
Conversation
(The main trick here that improves the wrapping of comments etc. is to use |
cab2cfa
to
bd4bb52
Compare
This is very cool and agree it looks much better Tom! Thank you! Would you be interested in looking into the two column vertical notation at some point as well? I know it's a different topic but while you're testing notation edge cases, you'll prob be the best man for the job 😀 #866 |
Well thanks for this! I know it is tricky to deal with. Quick review for now: I like it a lot, especially the way you handle sidelines and nesting. It it much more clear now. Making it look like the web UI, is a non goal to me, as I remind often. The app should have is own visual identity. Of course when the design is better in web we should copy it, as you did here. But we can also vary on some point where it makes sense. One thing I'm not sure of, for instance, are the italics. Looks like the rule in lichess website is to have an inside sideline italic. Why not... But I think I actually prefer having the comments in italic and keep the inline sideline as is (with a smaller font and a slight opacity). I'll review this carefully after I merge the challenges branch (which should be soon now). |
Yeah I stopped counting the knots this put into my brain :D
Yeah I get a that, I can change it. Using the Web UI as a reference, also for font styles etc. was just more convenient while developing/testing, but yeah no strong opinions on that, I'll adjust the style (or maybe it's even easier if you do it after merging the PR) |
Sure why not, but I'll work on the study feature for now, so don't expect anything to happen in the near future |
This screen also supports PGN import from random sources. The tree view should look good also in that case. Could you post a screenshot of the analysis tree when importing this PGN @tom-anders ? https://github.com/lichess-org/dartchess/blob/65fad86b26618785287152e437a7c80efb94b058/data/wcc_2023.pgn#L1-L39 Thanks! |
Huh, fun fact (or not fun), I tried importing them into a study via the web interface for comparison, but parsing failed: |
Thanks for that PGN, it uncovered a small bug when building sidelines, it's fixed now. I attached a video where I'm scrolling through the first game of the PGN. Note that there are some weird looking line breaks in some comments, but that's not a wrapping issue, those line breaks are actually there in the source PGN you posted. I'd assume that usually a PGN comment will only have intentional line breaks...? treeview.webm |
Thanks for the vid! I find it way more readable in your version, great job! There's one difference with what I did, the comments are shown in full length, where before only the first 5 lines where shown, and you'd tap on a comment to see the full version in a bottom sheet. I don't know if that change was intentional, but I actually like it, so let's keep it that way! |
One question, have you put a limit on nesting? I suppose we should have one. Or at least prevent further indentation when reaching a nesting threshold. |
Yeah that was intentional, especially for heavily commented PGNs and studies I thought that it would break your flow if you had to keep tapping comments to read them.
Ah yes good point, haven't implemented that yet - what would be a good threshold after which we stop increasing indentation? Something like 4 maybe? Also, we could by default hide deeply nested variations and display a + Icon instead like the website does, what do you think about that? |
No more than 4 seems right indeed
👍 |
Ok I checked the website, it's actually pretty aggressive when it comes to hiding variations: Only two levels of nesting are displayed by default, anything that's three or more levels is hidden by default. I guess unless we have a good reason not to, let's do the same for now..? |
Okay, added an indentation limit, collapse nesting>2 by default and added the plus-icon to expand variations. IMO this makes the "expand variations" action in the move context menu redundant, so I removed it. "Hide variations" works a little bit differently now, it used to only hide the variation you selected the move from, but now it hides all other sibling variations as well. I think it's more useful and intuitive this way, but curious to know what others think treeview.webm |
Great work! Yes, I think it should hide all variations. I wonder if the "plus" button is easy to tap? Seems a bit small. Also can you post again the screen recording with the WCC PGN with this new version? thanks! |
Yeah you're right, I made the icon bigger now. New video: treeview.webm |
Looks really great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of changes and this is complex code. I know this part is not much tested yet, but I think it would be nice to add some tests to analysis_screen_test
relating to what you changed.
Tests don't have to be extra complex first. Using simple PGN with variations, add some tests that check a few basic things:
- when the variation is indented
- when it is inline
- when it is collapsed
- ... etc
It important to start testing this because if later we have bug fixes to make in this tricky screen we'll be happy to have tests. (I shall add more tests for the rest of the analysis feature myself).
One last thing: this is a performance sensitive block. Have you tested the performance using a profile build on a real device? Using large trees to compare with before?
Thanks for the review!
Sure, I'll add some more tests 👍
Will do some before/after tests today, the WCC PGN is probably a good test here again |
I plan to reuse the new |
Okay, so I did some profiling, by loading the WCC PGN, selecting the first move (e4) and then pressing the "Next" Button, which should rebuild the entire tree view. In general, for both the Note that I did not enable stockfish for these tests (as that would lead to pretty much constant lag anyway) On the With this PR, it instead takes 100-120ms, followed by the frame that draws the indent lines, taking 50-60ms So yeah, it's a significant performance hit for very large trees like this. However, I also tested with https://github.com/lichess-org/dartchess/blob/65fad86b26618785287152e437a7c80efb94b058/data/lichess-bullet-game.pgn, which has mostly inline sidelines (but also two indented sidelines due to their length). With that PGN, |
Performance update: I've implemented an optimization that only rebuilds the subtree of the mainline that actually changed. With this optimization in place rendering the tree of the WCC PGN now only takes 15ms when switching a move within the same mainline subtree, and 30ms when switching the current move from one mainline subtree to another one (since then we need to redraw both the old and the new subtree in that case). Rendering the indents becomes pretty much negligible now. 🎉 Pretty impressive that with this optimization performance is even better than with the old code |
Ideally we'd include the debouncing and auto-scroll logic, but the debouncing relies on analysis controller. We'd need to refactor to have a common interface for analysis and study (and broadcast). Perhaps the easiest for now is to add the tests in the analysis_screen_test (so depending on the analysis controller), and we'll move the tests later when the common interface is done. |
Amazing! Great idea, I hadn't thought about it. |
Oh I forgot that I've already written an interface to make the So yeah, let's put it into the |
Sorry for the general lack of comments, with complex pieces of code like this that had many iterations until it ended up in its final state, I often find it hard to determine which parts need comments and which don't, especially for non-public classes (since at that point in your head everything seems obvious). Added some comments and also renamed stuff, let me know if anything is unclear still. |
a863fa1
to
0ecc30d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better with the documentation! Now I think I understand the logic :)
And thanks for the tests.
Especially for heavily commented PGNs this is now much more readable. We're also more consistent with the website now. I added screenhots for comparison below.
I know this is a rather big refactoring, and the recursive nature of this stuff is quite complex, so let me know if anything is unclear.
I also made a few style adaptions to be a bit more consistent with the the Web UI, but I don't have any strong opinions here, feel free to tweak the styling again after merging.
(Left: Before, Right: This PR)
lichess.org for comparison: